<template>
    <div class="newsinfo-container">
        <!--大标题-->
        <h3 class="title">{{ newsinfo.goods_name}}</h3>
        <!--子标题-->
        <p class="subtitle">
           简介:{{ newsinfo.shareDescription}}
        </p>
        <p class="subtitle">
            <span>时间:{{ newsinfo.xs_time | dateFormat}}</span>
            <span>点击:{{ newsinfo.goods_price}} 元</span>
        </p>

        <hr>

        <!--<div class="content" v-html="newsinfo.shareDescription">-->
            <!---->
        <!--</div>-->

        <!--内容区域-->
        <div class="content">
            <img :src="this.currentImg" alt="">
        </div>

        <!--评论子组件区域-->
        <comment-box :storeId="this.storeId"></comment-box>
    </div>
</template>

<script type="text/ecmascript-6">

    import { Toast } from 'mint-ui'

    //1.导入评论子组件
    import comment from '../subcomponents/comment.vue'

    export default {
        name: 'NewsInfo',
        data() {
            return {
                storeId: this.$route.params.storeId, //将 URL 地址中传递过来的Id值,挂载到 data 上,方便以后调用
                goodsId: this.$route.params.goodsId,
                newsinfo: {}, //新闻对象
                currentImg: '',
            }
        },
        created() {
            this.getNewsInfo();
        },
        methods: {

            getNewsInfo() { //获取新闻详情

                var pushData = {
                    goods_id: this.goodsId,
                    area_id: '',
                    store_id: this.storeId,
                    pp_id: '',
                }

                this.$http.post('mobile/index.php?act=goods&op=goods_detail',pushData).then(result => {
                    if (result.body.code == 200) {

//                        console.log(result)

                        this.newsinfo = result.body.datas.goods_info;
                        this.currentImg = result.body.datas.goods_image;

//                        Toast('获取详情成功!')

                    } else {

                        Toast('获取详情失败!')
                    }
                })

            }
        },
        components: {
            //用来注册子组件的节点
            "comment-box": comment
        }
    }
</script>


<style lang="scss" scoped rel="stylesheet/scss">

    .newsinfo-container {

        padding: 0 4px;

        .title {
            font-size: 16px;
            text-align: center;
            margin:15px 0;
            color: red;
        }

        .subtitle {
            font-size: 13px;
            color: #226aff;
            display: flex;
            justify-content: space-between;
        }

        .content {
            img {
                width:100%;
            }
        }
    }

</style>